﻿using B.S.Data.MES.API.Applications.QualityManagement.ExamineDesignCommand.Commands;
using B.S.Domain.BasicData.QualityManagement;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.QualityManagement.ExamineDesignCommand.CommandHandlers
{
    public class CreateExamineDesignCommandHandler : IRequestHandler<CreateExamineDesignCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<ExamineDesign> _examinedesignRepository;
        public CreateExamineDesignCommandHandler(IBaseRepository<ExamineDesign> examinedesignRepository)
        {
            _examinedesignRepository = examinedesignRepository;
        }
        public async Task<APIRequst<int>> Handle(CreateExamineDesignCommand request, CancellationToken cancellationToken)
        {
            ExamineDesign desin = new ExamineDesign();
            desin.DesignName = request.DesignName;
            desin.DesugbType = request.DesugbType;
            desin.InspectionMethod = request.InspectionMethod;
            desin.DesignValue = request.DesignValue;
            desin.ExamineProjectName = request.ExamineProjectName;
            desin.DesignDescription = request.DesignDescription;
            await _examinedesignRepository.Add(desin);

            return await Task.FromResult(new APIRequst<int>
            {
                Code = RequstCode.成功,
                Msg=RequstCode.成功.ToString()
            });


            

        }
    }
}
